<template>
  <div class="left">
    商品状态：<el-select
      v-model="value"
      placeholder="全部"
      @change="selectChange"
    >
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
  </div>
  <div class="shang">商品编号：</div>
  <div class="middle">
    <el-input v-model="input1" placeholder="请输入" key="" />
  </div>
  <div class="shang">商品名称：</div>
  <div class="right">
    <el-input v-model="input2" placeholder="请输入" />
  </div>
  <div class="btn">
    <el-button plain @click="send">查询</el-button>
    <el-button plain @click="clear">重置</el-button>
  </div>
</template>

<script>
import { ref } from "vue";
import mitt from "@/mock1/mitt.js";
export default {
  setup() {
    const value = ref("全部");
    const options = [
      {
        value: "全部",
        label: "全部",
      },
      {
        value: "已成功",
        label: "已成功",
      },
      {
        value: "未成功",
        label: "未成功",
      },
    ];
    const input2 = ref("");
    const input1 = ref("");
    const send = () => {
      mitt.emit("msg", { input1: input1.value, input2: input2.value });
    };
    const clear = () => {
      input1.value = "";
      input2.value = "";
      mitt.emit("mmg", { value: value.value });
    };
    const selectChange = (val) => {
      mitt.emit("mmg", { value: val });
    };

    return { value, options, input2, input1, send, clear, selectChange };
  },
};
</script>

<style lang="less" scoped>
.btn {
  float: left;
  margin-left: 30px;
}
.shang {
  float: left;
  margin-left: 50px;
  height: 30px;
  line-height: 30px;
}
.left {
  float: left;
}
.el-select {
  width: 100px;
  text-align: center;
}
.middle {
  width: 200px;
  float: left;
  margin-left: 5px;
}
.right {
  width: 200px;
  float: left;
  margin-left: 5px;
}
</style>
